<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Search results (${ fn:length(resultSet) })</title>
</head>
<body>

<c:if test="${ not empty sessionScope.user }">
	<a href="./LogoutController">Log out</a><br/>
</c:if>
<c:if test="${ empty sessionScope.user }">
	<a href="./login.jsp">Log in</a> <br>
	<a href="./register.jsp">Register</a><br/>
</c:if>
<a href="./HomeController">Home</a> <br/>
	
	<c:if test="${ not empty resultSet }">
		Results found: ${ fn:length(resultSet) }
	
		<table border="1">
			<thead>
				<tr>
					<td>No</td>
					<td>Photo preview</td>
					<td>Title</td>
					<td>Description</td>
					<td>Dimension</td>
				</tr>
			</thead>
		
			<tbody>
				<c:forEach var = "photo" items="${ resultSet }" varStatus="status">
					<tr>
						<td>${ status.count }</td>
						<td><a href="./ViewPhotoController?id=${ photo.id }"><img alt="No thumbnail." src="${photo.thumbnailLocation}"></a></td>
						<td>${ photo.title }</td>
						<td>${ photo.description }</td>
						<td>${ photo.width }x${ photo.height }</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</c:if>
	
	<c:if test="${ empty resultSet }">
		Search returned no results.
	</c:if>
	
</body>
</html>